<template>
  <!-- 用户管理 -->
  <div>
    <el-card class="box-card">
      <!-- 头部 -->
      <div slot="header" @click="handleBack" class="clearfix manage_header userManage_header">
        <!-- 返回 -->
        <i></i>
        <span>返回</span>
      </div>
      <!-- 新增用户 -->
      <div class="manage_user">
        <el-card>
          <h1>文章管理</h1>
          <div class="manage_right">
            <el-input placeholder="请选择日期" suffix-icon="el-icon-search" v-model="input1"></el-input>
            <el-button class="user_btn add_user" @click="newSubclass">
              <i></i>新增子类
            </el-button>
            <el-button class="user_btn del_user" @click="del_user">
              <i></i>删除子类
            </el-button>
          </div>
          <!-- 表格 -->
          <el-table
            :header-cell-style="{background:'#E9F4FD',color:'#212121',fontSize:'22px'}"
            class="user_table"
            :data="userData"
            style="width: 100%"
            @selection-change="handleSelectionChange"
            @row-click="handdle"
          >
            <el-table-column type="selection"></el-table-column>
            <el-table-column label="分类" prop="address"></el-table-column>
            <el-table-column  label="操作" width="300px">
              <template slot-scope="scope">
                <el-button @click="handleClick(scope.row)" type="text" size="small"
                 @click.stop>修改</el-button>
                <el-button
                  type="text"
                  size="small"
                  @click="handleArtDelete(scope.$index, scope.row)"
                   @click.stop
                >删除</el-button>
                <i class="shu"></i>
                <el-button
                  type="text"
                  size="small"
                  @click="handleRelease"
                  @click.stop
                >&nbsp 发布资讯</el-button>
              </template>
            </el-table-column>
          </el-table>
          <!-- 分页 -->
          <el-pagination
            class="fenye"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="currentPage4"
            :page-sizes="[100, 200, 300, 400]"
            :page-size="100"
            layout="total, sizes, prev, pager, next, jumper"
            :total="400"
          ></el-pagination>
          <!-- 模态框 -->
          <el-dialog
            class="delete"
            :visible.sync="Isdelete"
            :showClose="showClo=false"
            width="661px"
          >
            <i @click="Isdelete= false"></i>
            <i></i>
            <h2>删除该条反馈</h2>
            <p>
              啦啦啦，问题修好了吗？修好的话就点击确定按
              <br />钮，删除之前请再次确认是否修复完成。
            </p>
            <span slot="footer" class="dialog-footer">
              <el-button @click="handleSure">确 定</el-button>
              <el-button @click="Isdelete = false">取 消</el-button>
            </span>
          </el-dialog>
        </el-card>
      </div>
    </el-card>
    <!--  -->
  </div>
</template>

<script>
export default {
  data() {
    return {
      input1: "",
      userData: [
        {
          date: "2016-05-02",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1518 弄"
        },
        {
          date: "2016-05-04",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1517 弄"
        },
        {
          date: "2016-05-01",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1519 弄"
        },
        {
          date: "2016-05-03",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1516 弄"
        }
      ],
      // 索引
      index: "",
      // 是否删除模态框
      Isdelete: false,
      currentPage1: 5,
      currentPage2: 5,
      currentPage3: 5,
      currentPage4: 4
    };
  },
  methods: {
    handleBack() {
      this.$router.go(-1);
      // console.log(1);
    },
    handleClick(row) {
      console.log(row);
      this.$router.replace("/management");
    },
    // 点击新增子类
    newSubclass() {
      this.$router.replace("/newSubclass");
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
    },
    // 点击删除按钮
    handleArtDelete(index, row) {
      console.log(index, row);

      this.Isdelete = true;
      this.index = index;
      // console.log(this.index);
    },
    handdle(row, event, column) {
        // console.log(row);
        this.$router.replace('/article_information')
    },
    // 点击总删除按钮
    del_user() {
      // console.log(1);
      this.Isdelete = true;
    },
    // 点击复选按钮
    handleSelectionChange(val) {
      console.log(val);
    },
    // 点击确认
    handleSure() {
      this.Isdelete = false;
      console.log(this.index);
      let that = this;
      this.$confirm("确认删除？")
        .then(_ => {
          that.userData.splice(this.index, 1);
        })
        .catch(_ => {});
    },
    // 发布资讯
    handleRelease() {
        // console.log(11);
        this.$router.push('/add_article')
    }
  }
};
</script>

<style>
/* 头部 */
.clearfix:before,
.clearfix:after {
  display: table;
  content: "";
}
.clearfix:after {
  clear: both;
}
.manage_header {
  margin: 10px 0 10px 30px;
  position: relative;
}
.manage_header i {
  /* display: block; */
  position: absolute;
  top: 5px;
  left: 0;
  width: 10px;
  height: 20px;
  background: url("../assets/img/left.png") no-repeat;
  background-size: 10px 20px;
  vertical-align: middle;
}
.manage_header span {
  position: absolute;
  top: 0px;
  left: 22px;
  margin: 0;
  font-size: 20px;
  color: #3f51b5;
}
.manage_header h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 400;
  text-align: center;
  color: #212121;
}
.manage_user .el-card__header {
  padding: 0;
}
.userManage_header {
  padding-bottom: 24px;
}
/* 表格部分 */
.manage_user h1 {
  font-weight: 700;
  font-size: 32px;
  color: #4c4c4c;
  display: inline-block;
  margin: 0;
}
.manage_user .el-input {
  width: 276px;
  height: 40px;
}
.user_btn {
  border-radius: 5px;
  color: #fff;
  border: none;
}
.manage_right {
  float: right;
}
.manage_right .el-input {
  margin-right: 24px;
}
.add_user {
  background: #ff3c00;
}
.del_user {
  background: #bdbdbd;
}
.user_table {
  margin-top: 32px;
}
.user_table .el-table__header-wrapper {
}
.fenye {
  margin-top: 40px;
  text-align: center;
}
.fenye .el-input {
  width: 52px;
  height: 32px;
}
.user_table {
  font-size: 18px;
  color: #212121;
}
.user_table .el-button {
  font-size: 18px;
  color: #212121;
}
.user_table .el-table td,
.user_table .el-table th {
  text-align: center;
}

/* 模态框 */
.el-dialog {
  position: relative;
}
.delete i:nth-child(1) {
  position: absolute;
  top: 10px;
  right: 10px;
  display: block;
  width: 40px;
  height: 40px;
  background: url("../assets/img/close.png") no-repeat;
  background-size: 40px;
}
.delete i:nth-child(2) {
  display: block;
  margin: 0 auto;
  width: 38px;
  height: 38px;
  background: url("../assets/img/garbage.png") no-repeat;
  background-size: 38px;
}
.delete h2 {
  font-size: 24px;
  font-weight: 400;
  color: #212121;
  text-align: center;
  margin: 0;
  margin: 20px 0 28px;
  line-height: 47px;
}
.delete p {
  text-align: center;

  font-size: 16px;
  font-weight: 400;
  text-align: center;
  color: #757575;
}
.dialog-footer {
  margin: 0 50px 76px;
}
.dialog-footer .el-button {
  width: 240px;
  height: 47px;
  font-size: 18px;
  margin-bottom: 50px;
}
.dialog-footer .el-button:nth-child(1) {
  background: url("../assets/img/btn.png") no-repeat;
  background-size: 240px 47px;
  border: none;
  color: #fff;
}
.dialog-footer .el-button:nth-child(2) {
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 10px;
}
.shu {
    position: absolute;
    top: 20px;
    right: 190px;
    display: inline-block;
  width: 2px;
  height: 20px;
  background: #3040a0;
}
</style>